home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CRON_1
/
CRON_SET
/
CRON
/
CRON_DOC.TXT
< prev
next >
Wrap
Text File
|
1991-10-03
|
6KB
|
164 lines
CRON
╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
NAME
cron - clock daemon
DESCRIPTION
The cron daemon executes commands at specified dates and
times according to the instructions in the crontab file.
Since cron never exits, it should only be executed once.
This is best done by placing an alias to cron in the
System 7 "Startup Items" folder. Cron will then be exec-
uted automatically during system startup.
The crontab file consists of lines of seven fields each.
The fields are separated by spaces or tabs. The first five
fields are integer patterns that specify:
o Minute (0-59)
o Hour (0-23)
o Day of the month (1-31)
o Month of the year (1-12)
o Day of the week (1-7, with 1=Monday)
Each pattern can contain:
o A number in the range above
o Two numbers separated by a minus (-) sign means an
inclusive range
o A list of numbers separated by commas means any of the
numbers
o An asterisk (*) means all legal values
The sixth field is a user name. This is required for compat-
ibility, but is not currently used. Supply a dummy value in
this field.
The seventh field consists of all text on the line after the
sixth field, including tabs and spaces. This field is the
command that is executed at the specified times. If the
seventh field begins with "-b", the command that follows will
be executed in the background. Otherwise, commands are
initially launched into the forground.
Incorrectly constructed lines are ignored. No errors are
reported to the user.
The crontab file is examined by cron every minute, on the
minute.
Ultimately, cron should be setup as a faceless background task,
but for the moment, it still has a face, so it can be seen in
and selected from System 7's application menu. When cron is in
the foreground, hitting any key on the keyboard will cause it
to quit.
NOTES
Unlike the UNIX cron, a % character in the seventh and following
fields is not translated to a newline character.
Escape sequences are supported in all fields, so preceding a
character by a backslash (\) will cause the character to be
ignored for parsing purposes. In addition, the standard set of
escape sequences are supported:
\a alert (bell) character
\b backspace
\f formfeed
\n newline
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\? question mark
\' single quote
\" double quote
Hexadecimal (\xhh) and Octal (\ooo) sequences are not
currently supported, however.
Double quotes can be used to delimit fields. For example, the
file name "Captain╒s Suite" is interpreted as a single field if
it is surrounded by double quotes, but as two fields ("Captain╒s"
and "Suite") if the quotes are omitted. The parsing code is not
currently sensitive to single quotes.
CRON AS AN APPLICATION
Ultimately, cron will be a faceless background program which
won't appear in the application menu. For development purposes,
however, it's more convenient to allow it to show-up there. It
still doesn't have any sort of user interface, but you can (at
least) force it to quit by selecting it in the application menu
and hitting any key. Cron should quit immediately.
No user interface helps guarantee that cron runs in the smallest
possible amount of memory. It currently runs in 32K and will
probably work perfectly well in 20K.
Any user interface that is eventually created will be a separate
program.
ARGUMENT PASSING
If you are interested in writing commands for cron, read the
following. If not, ignore the rest of this file.
One of the things that makes cron capable of doing useful things
is its ability to pass arguments to the programs it executes.
Since the Mac OS has virtually no provision for argument passing,
a scheme had to be invented for cron.
Cron passes arguments to the programs it executes in a custom
AppleEvent. In order to get its arguments, a program must call
a routine named argcReceiver which will wait as much as one min-
ute for the appropriate AppleEvent to arrive. If the arguments
are not received within one minute, argcReceiver calls
ExitToShell to terminate the program.
ArgcReceiver takes two parameters: a pointer to an argc and an
argv variable. The call typically looks like this:
void main() {
int argc;
char **argv;
argcReceiver(&argc, &argv);
/* Put the rest of your main procedure down here.... */
}
Normally, you'll call ArgcReceiver before your main does anything
else. Once you've made the call, argc and argv will be filled out
*exactly* as they would be in a normal C programming environment.
So, apart from having to make this one procedure call at the start
of your main program in order to get your arguments, you can use
the arguments exactly as you're accustomed to doing so in other
environments, like UNIX.
Note that cron provides no support for stdin, stdout, stderr or
exit return values. Work is underway on a separate product that
will support all this and more, however.
The source code for argcReceiver is in the cron folder along with
the source code for argcBuilder -- a collection of routines which
make it fast and painless to assemble and transmit the argument
AppleEvents to other programs.